<template>
	<div>
		<!-- 面包屑导航 -->
		<el-breadcrumb separator-class="el-icon-arrow-right">
			<el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
			<el-breadcrumb-item>资讯系统</el-breadcrumb-item>
			<el-breadcrumb-item>员工签到</el-breadcrumb-item>
		</el-breadcrumb>
		<!-- 卡片式图 -->
		<el-card>
			<!-- 用户列表区 -->
			<el-table :data="userchecklist" border stripe style="width: 100%">
				<el-table-column prop="Id" label="编号" width="70"></el-table-column>
				<el-table-column prop="UserName" label="用户名" width="180"></el-table-column>
				<el-table-column prop="RoleNames" label="角色"></el-table-column>
				<el-table-column prop="Weight" label="权重"></el-table-column>
				<el-table-column prop="Cont" label="备注"></el-table-column>				
				<el-table-column label="操作">
					<template slot-scope="scope">
						<el-button type="warning" @click="setweight(scope.row)">编辑权重</el-button>
					</template>
				</el-table-column>
			</el-table>
			<!-- 分页区 -->
			
			<el-dialog title="修改分量" :visible.sync="editDialogVisible" width="50%">
				<el-form :model="editForm" :rules="editFormrules" ref="editFormRef" label-width="70px">
					<el-form-item prop="Weight" type="num" label="分量">
						<el-input  v-model="editForm.Weight"></el-input>
					</el-form-item>	
					<el-form-item prop="Cont"  label="备注">
						<el-input  v-model="editForm.Cont"></el-input>
					</el-form-item>					
				</el-form>
				<span slot="footer" class="dialog-footer">
					<el-button @click="editDialogVisible = false">取 消</el-button>
					<el-button type="primary" @click="onSubmit">确 定</el-button>
				</span>
			</el-dialog>
		</el-card>
	</div>
</template>

<script>
	export default {
		data(){
			return{
				userchecklist:[],
				editDialogVisible:false,
				editForm:{},
				editFormrules:{
					Weight:[
						{required:true,message:'请输入分量',trigger:'blur'}
					]
					
				}
			}
		},
		created(){
			this.getchecklist()
		},
		methods:{
			//获取签到用户分量信息
			async getchecklist(){
				const { data: res } = await this.$http.get('/api/api/Weight/updateCheckerList');
				console.log(res)
				if (res.code !== 0) return this.$message.error('获取数据失败');
				this.userchecklist = res.data;
			},
			setweight(row){
				this.editForm=row;
				this.editDialogVisible=true
				console.log(row)
			},
			//确定保存修改按钮
			async onSubmit(){
				const { data: res } = await this.$http.post('/api/api/Weight/editaskweight',this.editForm);
				console.log(res)
				if(res.code!==0)return this.$message.error(res.msg)
				this.$message.success(res.msg)
				this.editDialogVisible=false
				this.getchecklist()
			}
		}
	}
</script>

<style>
</style>
